package pers.cz.logtail.regedit;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;
import pers.cz.config.JefConfiguration;
import pers.cz.exception.ErrorCode;
import pers.cz.exception.RegisterException;
import pers.cz.logtail.config.RegisterConfigEnum;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: JefLogTail
 * @description: 直连注册表,直连就是客户端直接连接到服务端，客户端配置文件里面register.address地址也应该是服务端的地址
 * @author: Cheng Zhi
 * @create: 2023-10-05 08:50
 **/
public class DirectServiceRegedit extends AbstractServiceRegedit {

    static String address;

    static {
        address = JefConfiguration.get(RegisterConfigEnum.REGISTER_ADDRESS, "");
    }

    @Override
    public void registe(String serviceName, String serviceAddress) throws KeeperException, InterruptedException, Exception {
        // 直连时，服务端不需要注册
    }

    @Override
    public String getService(String serviceName) throws KeeperException, InterruptedException, Exception {
        return address;
    }

    @Override
    public void close() {
        address = null;
    }
}
